#!/bin/bash
set -e

# Get the configuration and action parameters.
proxied_ip=$(config-get proxied_ip)
login_password=$(config-get password)
home_domain=$(config-get home_domain)
number=$(action-get number)

if [ -z "$proxied_ip" ] || [ -z "$login_password" ] || [ -z "$home_domain" ] ; then
  echo Proxy not yet configured!
  exit 1
fi

# Delete the user.
sshpass -p$login_password ssh -o StrictHostKeyChecking=no ubuntu@$proxied_ip "echo $login_password | sudo -S /usr/share/clearwater/bin/delete_user -y $number $home_domain"
